<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@page import="Logic.Authorizer"%>
<%@page import="servlet.QualityManualDropDown"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%
	if (session.getAttribute("name") == null) {
		response.sendRedirect("login.jsp");
	} else {
		if (!Authorizer.checkRole("2", session.getAttribute("role")
				.toString())) {
			response.sendRedirect("nopermission.jsp");
		}
	}
%>

<jsp:include page="t_header.jsp" />

<!--  <div class="breadcrumbs_container">
	<article class="breadcrumbs"> <a href="QM_NewDeviationNotes.jsp">Manage Quality
		Manual</a>
	<div class="breadcrumb_divider"></div>
	<a class="current">Update Quality Manual</a> 
	</article>
</div> -->
<jsp:include page="header.html" />

<!-- Declare sidebar -->
<jsp:include page="t_sidebartry.jsp" />

<!-- Main Content -->
<body>
	<section id="main" class="column"> <article
		class="module width_3_quarter">
	<form id="SingleUpload" action="SingleUpload.jsp" method="post"
		enctype="multipart/form-data">
		<header>
		<h3>Update Quality Manual</h3>
		</header>
		<div class="module_content">
			<fieldset>
				<label>Type Of Manual</label> <select name="MT" id="MT"
					style="width: 80%">
						<option value="select">Select quality manual</option>
					<%
						QualityManualDropDown QMD = new QualityManualDropDown(out);
						QMD.doGet(request, response);
					%>
				</select>
			</fieldset>
			<!--  id needs to change to a more descriptive name -->
			<fieldset id="subcategoryFieldset">
				<label>Type</label>
				<input type="text" id="subcategory" name="subcategory"/>
			</fieldset>
			<fieldset id="fileUploadSection">
				<label>Document</label>
				<div style="width: auto; margin: 0 auto;">
					<input id="file" type="file" name="file" style="width: 85%;margin-left:2%;" />
				</div>
			</fieldset>
		</div>
		<footer>
		<div class="submit_link">
			<input id="Update" type="submit" value="Update"
				onclick="return verifyData()" class="alt_btn"> <input
				id="Clear" type="reset" value="Clear" onclick="Clear()"
				class="alt_btn">
		</div>
		</footer>
	</form>
	</article> <script type="text/javascript">
		function verifyData() {
			if ($('#file').val() == "") {
				alert('No file selected! Please select a file before pressing the Update button!');
				return false;
			} else {
				alert('File selected: ' + $('#file').val());
				var form = document.getElementById('SingleUpload');
				form.action = "SingleUpload.jsp?MT="
						+ document.getElementById('MT').value;
				form.submit();

				return true;
			}
		}
		function selectTest()
		{
		

		}
		$('#MT').change(function()
				{
			if($('#MT').find(':selected').text() == "Select quality manual")
			{
				$('#fileUploadSection').hide();
				$('#Update').hide();	
				$('#Clear').hide();
			}else if($('#MT').find(':selected').text() == "Standard Operating Procedures")
			{
				$('#subcategoryFieldset').show();
			}
			else{
				$('#fileUploadSection').show();
				$('#Update').show();	
				$('#Clear').show();
			}
				});
		$(document).ready(function()
		{
			$('#Update').hide();
			$('#fileUploadSection').hide();
			$('#subcategoryFieldset').hide();
		});
		
		function Clear() {
			document.getElementById('SingleUpload').reset();
			return false;
		}
	</script>
	<div class="spacer"></div>
	</section>
</body>



